package com.javaee.xiangyang.converter;

import com.javaee.xiangyang.entity.enmu.impl.UserState;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

@Component
public class UserStateConverter implements Converter<String, UserState> {

    @Override
    public UserState convert(String string) {
        for (UserState userState: UserState.values()) {
            if (userState.getCode() == Integer.parseInt(string)){
                return userState;
            }
        }
        return null;
    }
}
